package m.jclecai.com.fragment.bifen;


import android.app.Fragment;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import m.jclecai.com.R;
import m.jclecai.com.adapter.CommonPagerAdapter;
import m.jclecai.com.base.BaseFragment;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link BiFenChildFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class BiFenChildFragment extends BaseFragment {
    // TODO: Rename parameter arguments, choose names that match
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;
    @BindView(R.id.tl_bifen_child)
    TabLayout tl_bifen_child;

    @BindView(R.id.vp_bifen_child)
    ViewPager vp_bifen_child;

    private List<android.support.v4.app.Fragment> list;

    public BiFenChildFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.
     * @return A new instance of fragment BiFenChildFragment.
     */
    // TODO: Rename and change types and number of parameters
    public static BiFenChildFragment newInstance(int param1) {
        BiFenChildFragment fragment = new BiFenChildFragment();
        Bundle args = new Bundle();
        args.putInt(ARG_PARAM1, param1);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void initView() {
        initViewPager();
    }

    private void initViewPager() {
        list = new ArrayList<>();
        list.add(BiFenChild_ChildFragment.newInstance("", ""));
        list.add(BiFenChild_ChildFragment.newInstance("", ""));
        list.add(BiFenChild_ChildFragment.newInstance("", ""));
        list.add(BiFenChild_ChildFragment.newInstance("", ""));
        vp_bifen_child.setAdapter(new CommonPagerAdapter(getActivity(), list, R.array.bifen_zuqiu_child_title, getChildFragmentManager()));
        vp_bifen_child.setOffscreenPageLimit(5);
        tl_bifen_child.setupWithViewPager(vp_bifen_child);
        vp_bifen_child.setCurrentItem(getActivity().getIntent().getIntExtra("order_position", 0), false);
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_bi_fen_child;
    }



}
